﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class AreaRestrita_PopUpFotos : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string pasta = Request.QueryString["pasta"].ToString();
        if (pasta != string.Empty)
        {
            DirectoryInfo Diretorios = new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["PastaReal"].ToString() + "\\" + pasta + "\\Thumbnails");
            rptVeiculos.DataSource = Diretorios.GetFiles();
            rptVeiculos.DataBind();
        }       
    }
    protected void rptVeiculos_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            FileInfo foto = (FileInfo)e.Item.DataItem;
            Image imgAutomovel = (Image)e.Item.FindControl("imgAutomovel");
            String[] caminho = foto.FullName.Split('\\');
            imgAutomovel.ImageUrl = System.Configuration.ConfigurationManager.AppSettings["PastaVirtual"].ToString() + caminho[caminho.Count() - 3] + "/Thumbnails/" + foto.Name;      
        }
    }
}